<?php
/**
 * 签到验证器
 * @author 王勇程 <laughskydragon@qq.com>
 */

namespace app\common\validate;

class Checkin extends ValidateBase
{
    // 验证规则
    protected $rule = [
        'user_id'         => 'require|integer|gt:0',
        'checkin_date'    => 'require|date',
        'points'          => 'require|integer|egt:0',
        'continuous_days' => 'require|integer|egt:0',
    ];

    // 验证提示
    protected $message = [
        'user_id.require'         => '用户ID不能为空',
        'user_id.integer'         => '用户ID必须为整数',
        'user_id.gt'              => '用户ID必须大于0',
        'checkin_date.require'    => '签到日期不能为空',
        'checkin_date.date'       => '签到日期格式不正确',
        'points.require'          => '签到积分不能为空',
        'points.integer'          => '签到积分必须为整数',
        'points.egt'              => '签到积分不能为负数',
        'continuous_days.require' => '连续签到天数不能为空',
        'continuous_days.integer' => '连续签到天数必须为整数',
        'continuous_days.egt'     => '连续签到天数不能为负数',
    ];

    // 应用场景
    protected $scene = [
        'add'    => ['user_id', 'checkin_date', 'points', 'continuous_days'],
        'edit'   => ['points', 'continuous_days'],
        'query'  => ['user_id'],
    ];
}